package com.xxxx.crm.controller;

import com.xxxx.crm.base.BaseController;
import com.xxxx.crm.query.BCustomerQuery;
import com.xxxx.crm.service.BCustomerService;
import com.xxxx.crm.service.CustomerService;
import com.xxxx.crm.vo.BCustomer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

@RequestMapping("customer")
@Controller
public class CustomerController  extends BaseController {

    @Resource
    private CustomerService customerService;

    @Resource
    private BCustomerService bCustomerService;

    /**
     * 进入客户管理的默认页面
     * @return
     */
    @RequestMapping("index")
    public  String index(){
        //返回视图页面src/main/resources/views/BCustomer/customer.ftl
        return "BCustomer/customer";
    }

    /**
     * 分页查询客户列表
     * @param bCustomerQuery
     * @return
     */
    @RequestMapping("list")
    @ResponseBody
    public Map<String,Object> queryCustomerByParams(BCustomerQuery bCustomerQuery){
        return bCustomerService.queryCustomerByParams(bCustomerQuery);
    }

    /**
     * 查询客户构成，生成折线图
     * @return
     */
    @RequestMapping("countCustomerMake")
    @ResponseBody
    public Map<String,Object> countCustomerMake(){
        //return customerService.countCustomerMake();
        return bCustomerService.countBCustomerMake();
    }



    /**
     * 查询客户构成，生成饼状图
     * @return
     */
    @RequestMapping("countCustomerMake02")
    @ResponseBody
    public Map<String,Object> countCustomerMake02(){
       // return customerService.countCustomerMake02();
        return bCustomerService.countBCustomerMake02();
    }

    /**
     * 客户统计条线图
     * @return
     */
    @RequestMapping("customerBalanceAvg")
    @ResponseBody
    public Map<String,Object> customerBalanceAvg(){
        return bCustomerService.customerBalanceAvg();

    }

    @RequestMapping("customerProductAvg")
    @ResponseBody
    public Map<String,Object> customerProductAvg(){
        return bCustomerService.customerProductAvg();

    }

    @RequestMapping("customersalaryAvg")
    @ResponseBody
    public Map<String,Object> customersalaryAvg(){
        return bCustomerService.customersalaryAvg();

    }


    @RequestMapping("customersatisfactionAvg")
    @ResponseBody
    public Map<String,Object> customersatisfactionAvg(){
        return bCustomerService.customersatisfactionAvg();

    }
}
